
package rowan.application.quickaccess;

import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;


public class ExtrasPage extends Activity implements OnClickListener{
	private String[] tips;
	private int tipIndex= 0;
	private TextView currentTip;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.extras);
		
		tips = getResources().getStringArray(R.array.tips);
		currentTip = (TextView)findViewById(R.id.tipdisplay);
		
		setListeners();
		
	
	}

	public void nextTip()
	{
		tipIndex++;
		if (tipIndex > tips.length-1)
			tipIndex =0;
		currentTip.setText(tips[tipIndex]);
	}
	
	public void previousTip()
	{
		tipIndex--;
		if (tipIndex < 0)
			tipIndex = tips.length-1;
		currentTip.setText(tips[tipIndex]);
	}
	
	public void setListeners()
	{
		
	// Arrow Buttons
		Button b = (Button)findViewById(R.id.foward);
		b.setOnClickListener(this);
		b = (Button)findViewById(R.id.backward);
		b.setOnClickListener(this);
		
	// Safe Walk Listeners
		ImageView iv = (ImageView)findViewById(R.id.callSafe);
		iv.setOnClickListener(this);
		
		iv = (ImageView)findViewById(R.id.shuttles);
		iv.setOnClickListener(this);
	
	//  MAIL SERVER SETTINGS
        TextView setting = (TextView)findViewById(R.id.incoming);
        setting.setOnClickListener(this);
        
        setting = (TextView)findViewById(R.id.outgoing);
        setting.setOnClickListener(this);
        setting.setText(setting.getText());
	}
	
	@Override
	public void onClick(View v) {
		
		LinearLayout layout;
		TextView settings;
		Dialog dialog;
		Intent intent;
		
		switch(v.getId()){
		
		case R.id.incoming:
			layout = new LinearLayout(this);
			layout.setOrientation(LinearLayout.VERTICAL);
			
			settings = new TextView(this);
			settings.setText("-USERNAME \n(username)@students.rowan.edu\n" +
								"\n-PASSWORD \n(your password)\n" +
								"\n-IMAP \nimap.gmail.com\n" +
								"\n-PORT \n933\n" +
								"\n-SECURITY TYPE \nSSL (Accept all certificates)\n");
			settings.setPadding(20, 20, 20, 20);
			layout.addView(settings);
			
			dialog = new Dialog(this);
			dialog.setContentView(layout);
			dialog.setTitle("Incoming Server Details");
			dialog.show();
			break;
			
		case R.id.outgoing:
			layout = new LinearLayout(this);
			layout.setOrientation(LinearLayout.VERTICAL);
			
			settings = new TextView(this);
			settings.setText("-SMTP SERVER \nsmtp.gmail.com\n" +
								"\n-PORT \n465\n" +
								"\n-SECURITY TYPE \nSSL (Accept all certificates)\n" +
								"\n-USERNAME \n(username)@students.rowan.edu\n" +
								"\n-PASSWORD\n(Your password)\n");
			settings.setPadding(20, 20, 20, 20);
			layout.addView(settings);
			
			dialog = new Dialog(this);
			dialog.setContentView(layout);
			
			
			
			dialog.setTitle("Outgoing Server Details");
			dialog.show();
			break;
		
		case R.id.callSafe:
			intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:8562567233"));
			startActivity(intent);
			break;
			
		case R.id.shuttles:
			intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.rowan.edu/map/images/shuttleroute.png"));
			startActivity(intent);
			break;
			
		case R.id.foward:
			nextTip();
			break;
			
		case R.id.backward:
			previousTip();
			break;
		
		}
	}
}